package com.hc.gen;

import com.hc.common.utils.RandomUtil;
import com.hc.domain.Author;
import com.hc.domain.User;
import com.hc.mapper.AuthorMapper;
import com.hc.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hecai
 */
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class DataInitUtil {

//    @Resource
//    private AuthorMapper authorMapper;
//
//    @Test
//    void initAuthor() {
//        List<Author> list = new ArrayList<>();
//        for (int i = 0; i < 300; i++) {
//            final String tel = RandomUtil.genPhoneNum();
//            final Author author = Author.builder()
//                    .nickname(RandomUtil.genChineseName())
//                    .avatar("http://bing-images.oss-cn-beijing.aliyuncs.com/aa/bb/male1638154958151.jpg?Expires=4791754961&OSSAccessKeyId=LTAI5tLtkK4xeo3EY5wmBcF1&Signature=YOWSIX04b6B9FXPVBidIOB0Cwt8%3D")
//                    .gender(RandomUtil.genInteger(1,3))
//                    .tel(tel)
//                    .email(RandomUtil.genEmail(16))
//                    .qq(RandomUtil.genString(1,10))
//                    .wechat(tel)
//                    .info(RandomUtil.genString(6,120))
//                    .status(RandomUtil.genInteger(0,2))
//                    .createTime(RandomUtil.genLocalDateTime("1995-1-1 00:00:00","2000-12-30 24:00:00"))
//                    .updateTime(RandomUtil.genLocalDateTime("2010-1-1 00:00:00","2020-12-30 24:00:00"))
//                    .build();
//            list.add(author);
//        }
//        authorMapper.batchInsert(list);
//    }

//    @Resource
//    private UserMapper userMapper;
//
//    @Test
//    void initAuthor() {
//        List<User> list = new ArrayList<>();
//        for (int i = 0; i < 300; i++) {
//            final String tel = RandomUtil.genPhoneNum();
//            final User user = User.builder()
//                    .nickname(RandomUtil.genChineseName())
//                    .avatar(RandomUtil.genString(6,10))
//                    .account("http://bing-images.oss-cn-beijing.aliyuncs.com/aa/bb/male1638154958151.jpg?Expires=4791754961&OSSAccessKeyId=LTAI5tLtkK4xeo3EY5wmBcF1&Signature=YOWSIX04b6B9FXPVBidIOB0Cwt8%3D")
//                    .password(RandomUtil.genString(5,8))
//                    .gender(RandomUtil.genInteger(1,3))
//                    .tel(tel)
//                    .email(RandomUtil.genEmail(16))
//                    .qq(RandomUtil.genString(1,10))
//                    .wechat(tel)
//                    .salt("")
//                    .info(RandomUtil.genString(6,120))
//                    .status(RandomUtil.genInteger(0,2))
//                    .createTime(RandomUtil.genLocalDateTime("1995-1-1 00:00:00","2000-12-30 24:00:00"))
//                    .updateTime(RandomUtil.genLocalDateTime("2010-1-1 00:00:00","2020-12-30 24:00:00"))
//                    .build();
//            list.add(user);
//        }
//        userMapper.batchInsert(list);
//    }

}
